package cn.psvmc.cxzapi.enums;

public enum ResultCode {

    // 相应代码+内容
    NO_VALUE(-1, "找不到该错误信息！"),
    SUCCESS(0, "操作成功！"),
    FAIL(1, "操作失败！"),


    TOKEN_ADD_ERROR(1, "加入缓存出错！"),
    TOKEN_NOTEXISTS(2, "登录失效！"),
    AUTH_SN_NOTEXISTS(1, "设备未授权！"),
    AUTH_SN_EXISTS(1, "请解绑原设备再试！"),
    AUTH_ACCOUNT_EXISTS(1, "账号已存在！"),
    AUTH_ACCOUNT_NOTEXISTS(1, "账号不存在！"),
    AUTH_CREDENTIAL_ERROR(1, "密码错误！"),
    AUTH_ACCOUNT_DISABLED(1, "此账号禁用！"),
    AUTH_ACCOUNT_DELETED(1, "账号不存在！"),
    AUTH_LOGION(1, "用户已在其他设备登录！"),
    PHONE_ERROR(1, "手机号不合法！"),
    PHONE_EXISTS(1, "手机号已被绑定！"),
    MSG_ERROR(1, "验证码有误！"),
    MSG_NOTEXISTS(1, "验证码失效！"),
    REGION_SCHOOL_LOCK(1, "账号已锁定，请联系管理员！"),
    NO_POWER(1, "没有操作权限！"),
    NO_USER_ERROR(1, "用户不存在！"),
    ACCOUNT_LOCKED(1, "账号已被锁定，请联系管理员！");

    /**
     * 枚举代码
     */
    private int code;

    /**
     * 枚举描述
     */
    private String msg;


    ResultCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }


    public void setCode(int code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static ResultCode getByValue(Integer value) {
        ResultCode resultCode = ResultCode.NO_VALUE;

        for (ResultCode resultEnums : ResultCode.values()) {
            if (Integer.valueOf(resultEnums.code).equals(value)) {
                return resultEnums;
            }
        }
        return resultCode;
    }
}
